package lee.com.mqttlibrary.util;

import java.util.LinkedList;

/**
 * CreateDate：18-11-1 on 下午5:27
 * Describe:
 * Coder: lee
 */
public class InLimitList extends LinkedList<Long> {

    private static final int SIZE = 99;

    public static InLimitList getInstance() {
        return InLimitList.LimitListHolder.instance;
    }

    private static class LimitListHolder {
        private static final InLimitList instance = new InLimitList();
    }

    public InLimitList() {
        super();
    }


    public boolean add(long id) {
        for (Long callId : getInstance()) {
            if (id == callId) return false;
        }

        if (size() > SIZE){
            removeFirst();
        }

        return super.add(id);
    }

}
